var adWuKong = require ('../../ads/wuKong/index');
const pointMap = require ('./pointMap');
var {
  randomUtils,
  textUtils,
  ocrUtils,
  clickContent,
  clickOneContent,
  existContent,
  clickUtils,
} = require ('../../utils/index');
var TypeEnum = {
  看视频领取: '0',
};

module.exports = {
  init () {
    if (this.checkSuprise ()) {
      return;
    }
    if (this.checkVideo ()) {
      return;
    }
    if (this.checkOver ()) {
      return;
    }
  },
  checkSuprise () {
    var content = '恭喜你获得惊喜奖励';
    if (existContent (content)) {
      clickUtils.clickPointMap (pointMap.任务.惊喜视频.关闭);
      sleep (randomUtils.getRandom (3.5, 5, 1000));
      this.init ();
      return true;
    }
    return false;
  },
  checkVideo () {
    var contents = ['看视频领取', '再看一条领', '看视频额外再领', '看视频再领'];
    if (clickOneContent (contents)) {
      sleep (randomUtils.getRandom (3.5, 5, 1000));
      adWuKong.startWatchAd ();
      this.normal = adWuKong.normal;
      if (this.normal) {
        this.init ();
      }
      return true;
    }
    return false;
  },
  checkOver () {
    var content = '开心收下';
    if (clickContent (content)) {
      sleep (randomUtils.getRandom (3.5, 5, 1000));
      this.init ();
      return true;
    }
    return false;
  },
};
